package com.ai.service.made.impl;

import com.ai.entity.network.L2ToDsSysMessage;
import com.ai.mapper.plc.L2ToDsMapper;
import com.ai.networking.netty.service.SendMessage;
import com.ai.service.made.IL2SignalService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import java.time.LocalDateTime;


@Service
public class IL2SignalServiceImpl implements IL2SignalService {

    @Resource
    private L2ToDsMapper l2ToDsMapper;

    @Override
    public void receiveSignal(L2ToDsSysMessage message) {
        //查找最新的数据
//         L2ToDsSysMessage l2ToDsSysMessage = l2ToDsMapper.selectOne();
        //对比message与l1ToDsSysMessage的不同
//        if (!message.equals(l2ToDsSysMessage)){
            message.setCreateTime(LocalDateTime.now());
            l2ToDsMapper.save(message);
            String code = "AG_C";
            SendMessage.sendMessage(code,message);
            code = "SI_S";
            SendMessage.sendMessage(code,message);
//        }
    }
}
